package cn.longwingstech.intelligence.agent.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.longwingstech.intelligence.agent.common.BaseResponse;
import cn.longwingstech.intelligence.agent.common.ResultUtils;
import cn.longwingstech.intelligence.agent.model.vo.app.AppAndHistoryVO;
import cn.longwingstech.intelligence.agent.model.vo.app.AppVO;
import cn.longwingstech.intelligence.agent.service.AppService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/app")
@Tag(name = "app控制层")
@SaCheckLogin
public class AppController {

    @Resource
    private AppService appService;

    /**
     * 用户获取app历史记录
     * @param appid
     * @return
     */
    @GetMapping("/getByAppAndHistoryByAppid")
    @Operation(summary = "用户获取app历史记录")
    public BaseResponse<AppAndHistoryVO> getByAppAndHistory(Long appid) {
        AppAndHistoryVO result = appService.getAppAndHistory(appid);
        return ResultUtils.success(result);
    }

    /**
     * 用户获取app历史记录列表
     * @return
     */
    @GetMapping("/getByAppAndHistoryList")
    @Operation(summary = "用户获取app历史记录列表")
    public BaseResponse<List<AppAndHistoryVO>> getByAppAndHistoryList() {
        List<AppAndHistoryVO> result = appService.getAppAndHistoryList();
        return ResultUtils.success(result);
    }

    @GetMapping("/getAppList")
    @Operation(summary = "用户获取app列表")
    public BaseResponse<List<AppVO>> getAppList() {
        List<AppVO> result = appService.getAppList();
        return ResultUtils.success(result);
    }
}
